Welcome to Bryton in three hours.
Let's talk about lists to develop a list, you simply define a name for your list, for example, Miley's
equals to open and close brackets and you separate different elements of your list using comma, for
example, I define a list here, Miles equals to open and close brackets.
So this is one bracket.
This is another bracket.
And then I have multiple commands like here, here and go on and right before each comma, I have some
value or the string or boolean or other data formats here, for example, as the first element, I have
one and I have a string here, then a boolean here, then a float number here, a mathematical expression
here, a logical explanation here and a string with that formal function.
And even as the last element of my list, I have another list assemblies with some element.
I'm going to print this list saying that this is my list column and then I'm going to use Backslash
N to start a new line.
And then in that new line, I'm going to print whatever I want to print in my calibrate, which is minus.
Let's run this up.
This is my list.
And on the new line, I'm going to print my list as I define it up here.
You can call different elements of your list in part on similar to many programming languages.
The indexing starts from zero.
That means that is number one here.
The corresponding index in that my list is zero.
This index number one, index number two and go on.
So if I want to call the first element of my list, I have to use index zero for indexing.
We always use open and close brackets and put the corresponding indexes within the brackets.
So remember, functions go with Prentice's and indexing always goes with brackets.
So if I want to call the first element of my list, I say Miley's open and close brackets and the corresponding
index, which is zero.
If I want to call the third element of my list, which is a boolean, its index is two or its element
number is two.
So I can say, for example, Y equals two miles open and close brackets and within the brackets.
Number two, in Python, we have also negative indexing.
If you want to call the last element of your list, which is a surplus, then you can call that with
index minus one.
The element before the last element of your list is element number minus two.
And go on in order to call a range of elements in your list, you first define the first index user
column and the last index number that you want to get from that list.
For example, my list open and close brackets and my number zero two and number three.
But what happens here is it gets element number three, it gets element number one and number two.
But number three.
So whatever value put here, it gets whatever elements this list has right before that.
If you want to call all the elements after and element number, you simply say, for example, very
close to my list of close brackets, that element number, let's say three and then column.
And you don't need to define anything after that.
And it gets whatever from number three, including number three.
By the end, if you want to get all the elements of the least up to an index, you don't have to define
the first element.
But use a column and then the number that you want to get the elements right before it.
So in this example, it gets element number zero and one.
But you can also use ranges of indexes using negative indexing.
For example, you want element number minus three to element number minus one.
This is minus one.
This is minus two and this is minus three.
So it gets this one.
This one, but this one.
So it gets minus three and minus two, but minus one.
Let's say if you want to get the third element of your sublist, we know that the index corresponding
to my surplice could be either seven as the index of the last element in this list or minus one.
So I use minus one here.
And whatever comes out of it is that sublist.
Then the third element of that subleased its corresponding index is two.
So you can open and close another bracket and put two here and it gets that boolean element of that
this round itself.
So once around the cell, everything is being memorized in my memory.
So in my memory or workspace, I have all these variables because I ran this one time when you on a
cell, it gets a cell number here, for example, number 13.
And if you compare it to this cell, you see that this one is number two and this is number 13.
And that means that this cell has been wrong before this cell or this cell has been run after this cell.
That means that since I have all the elements of this cell in my memory, I can use them in this cell
and run this cell again.
And in that case, the cell number here.
Becomes 14, and it means that this cell has been run after this.
So we have to pay attention to this cell numbers and the order the cells are being drawn in our Google
collaborator notebook.
Let's print all these variables here.
So here, for example, I say print over unclosed single quotations.
And here I have, for example, X is column and then I have come on here and I have that X variable
to print it for me.
And similarly, I have print for Y to CU as run this.
And here are all of your elements.
For example, the third element of your sublist is true, which we call it using this very index.
A very interesting feature of lists is appending appending means, adding something to the end of your
list.
In this example, I'm using my list that append function.
So remember, if you type my list here, for example, and you put a dot here, you see a bunch of functions
are being popped up.
Whatever comes with Purple Cube is a building function or corresponding to that variable.
And here it is a list.
One of these functions is up and then you can open and close.
Prentice's are really explanations here.
I'm going to remove this as an example.
I have my list that apon open and close prentice's and I have a string here.
Lists are appended.
Let's print my list.
So now my last element of my list is not a subleased anymore, but that string, that list are amendable.
If I run this again then another list or amendable added to the end of my list.
Let's talk about two apples, two bills are very similar to lists, but instead of brackets, they use
practices and then similar to lists, we separate the elements of my tuple using commas.
This is an example of my tuple, which has different types of values, strings and even a as eight different
elements.
So in this example, I have five elements for my tuple.
Let's pretend this is my tuple in a new line.
I'm going to print my tupa.
Let me change it to my Tuko.
Yes.
As Fundis.
And here this is my tuple and it has been printed here for you to indexing is exactly the same as lists.
So I'm going to have that example that we had here for copied here by inside of my list.
I have my Tupa list fundis and here we're going to print them all for you.
Similar to my list, the major difference between two poles and leaves is the fact that pupils are not
dependable.
However, you can append tuple to your list.
For example, here I'm saying list that apon apparently is prentice's my tuple.
I'm going to print for you, Miles.
As you see here, the last element of my list is now my tuple.
Let's talk about dictionaries, dictionaries are also similar to lists and typos, but here, instead
of brackets or practices, we use curly braces and then separate different elements of my dictionary.
Using the other different here is that each element of your dictionary has two components which are
divided from each other using a column on the left side of the column.
We have a string, which is the key value of that particular element, and on the right side of the
column we have the value or object corresponding to that.
Kikhia, I define a dictionary with three elements.
This is the first element.
This is the second element.
And this is the third and last element.
Each element has a key value and the corresponding object or value.
For example, the first element has Koening one as its key name and the mileage that we have defined
before, and it is already in my memory as the corresponding value to that key.
The second element has Kinnane two and my tuple as its value and the third element as Kinnane three
and the type of, let's say, 23 has its value.
You can also have mathematical operations here.
Let's run this and look into my dictionary.
You see, we have different keys.
This is Carnavon, the corresponding value Koening to the corresponding value or my tuple and Kinnane
three and the corresponding value, which is the type of 23 and that is integer.
You can grab all the keys of your dictionary using my dictionary, dot the key function open and close
practices, and you don't have to put anything over there.
It just grabs for you the keys of your dictionary and reserve it in my dictionary keys.
Let's print my dictionary.
Keys are open and close calibrates says that format my dictionary keys.
Let me put it back again here to print my dictionary keys in the front cell and here they have my dictionary
keys.
But as you see, the format is in the form of dict keys.
You can use the building list function to turn that my dictionary keys into a.
So here I said my dictionary keys equals to least open and close parentheses my dictionary keys and
this removes that dict format and turn it into a lease and save it as my dictionary keys.
And here I'm going to print it for you in a new line.
As long as you see my dictionary keys is a list of three elements and each element is a string corresponding
to a key in addition to the indexing in dictionaries.
Again, you open and close brackets and here, instead of an index number, you put the key corresponding
to the element that you want to call, for example, here, the value corresponding to the second key
in our dictionary, they have a name, two in a string has the index of my dictionary.
If you run this, it gives you my tuple.
You can also use that my dictionary keys, which is in the form of a list here to call values corresponding
to different elements of your dictionary.
For example, I want to grab Kinnane two and the corresponding index to that key name two is one because
this is zero.
This is one.
And this is two.
So I say my dictionary keys open and close brackets one.
And the result of this is that string, which is he named two.
And then the outer bracket sees the string key name two within it, and then it becomes something like
this one and then return for you the corresponding value to the dictionary key, which is key named
Israelis.
And here again, we have Matobo.
In this lecture, you learn about some python building functions, how to create python lists, tuples
and dictionaries, how to cull elements of python lists to and dictionaries, how to create strains
and print information, and how to perform basic mathematics in Python in the next lecture.
We will learn about loops conditional on scripts and function.
Thank you for your attention.
See you all in the next lecture.